package com.ssyx.product.controller;

import com.ssyx.common.result.Result;
import com.ssyx.product.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName:FileUploadController
 * Description:
 *
 * @Author kay
 * @Create 2024/3/29 17:38
 * @Version 1.0
 */
@RestController
@RequestMapping("/admin/product")
//@CrossOrigin
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file){ //此处参数名file是固定的，不能是其他的名字
        //1.获取上传的文件
        //2.调用service的方法上传，返回minio路径
        String url = fileUploadService.upload(file);
        return Result.ok(url);
    }
}
